<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>(ES6)解构赋值</title>
</head>

<body>
    <script>
        //按照数组元素位置对应赋值
        var [a, b] = [10, 20, 30];
        var [a, b, c, d] = [10, 20, 30];
        console.log(a);
        console.log(b);
        console.log(c);
        console.log(d);

        //对象的解构赋值是按照属性名是否等于变量名
        //变量需要被赋值为指定属性的值，  属性名：变量名
        var p = { name: 'zs', age: 16, score: 90 };
        // var { name, age, score } = p;
        var { score, age, name } = p;
        console.log('name=' + name);
        console.log(age);
        console.log(score);
    </script>
</body>

</html>